package com.easy.cloud.web.module.certification.biz.converter;

import com.easy.cloud.web.component.core.util.BeanUtils;
import com.easy.cloud.web.module.certification.api.dto.DisabilityLevelDTO;
import com.easy.cloud.web.module.certification.api.vo.DisabilityLevelVO;
import com.easy.cloud.web.module.certification.biz.domain.DisabilityLevelDO;
import org.springframework.data.domain.Page;

import java.util.List;
import java.util.stream.Collectors;

/**
 * DisablityLevel转换器
 *
 * @author Fast Java
 * @date 2024-04-02 20:43:33
 */
public class DisabilityLevelConverter {

    /**
     * DTO转为DO
     *
     * @param disabilityLevel 转换数据
     * @return com.easy.cloud.web.module.certification.biz.domain.DisabilityLevelDO
     */
    public static DisabilityLevelDO convertTo(DisabilityLevelDTO disabilityLevel) {
        DisabilityLevelDO disabilityLevelDO = DisabilityLevelDO.builder().build();
        BeanUtils.copyProperties(disabilityLevel, disabilityLevelDO, true);
        return disabilityLevelDO;
    }

    /**
     * DO转为VO
     *
     * @param disabilityLevel 转换数据
     * @return com.easy.cloud.web.module.certification.api.vo.DisabilityLevelVO
     */
    public static DisabilityLevelVO convertTo(DisabilityLevelDO disabilityLevel) {
        DisabilityLevelVO disabilityLevelVO = DisabilityLevelVO.builder().build();
        BeanUtils.copyProperties(disabilityLevel, disabilityLevelVO, true);
        return disabilityLevelVO;
    }

    /**
     * 列表DO转为VO
     *
     * @param disabilityLevels 转换数据
     * @return com.easy.cloud.web.module.certification.api.vo.DisabilityLevelVO
     */
    public static List<DisabilityLevelVO> convertTo(List<DisabilityLevelDO> disabilityLevels) {
        return disabilityLevels.stream()
                .map(DisabilityLevelConverter::convertTo)
                .collect(Collectors.toList());
    }

    /**
     * 分页DO转为VO
     *
     * @param page 转换数据
     * @return com.easy.cloud.web.module.certification.api.vo.DisabilityLevelVO
     */
    public static Page<DisabilityLevelVO> convertTo(Page<DisabilityLevelDO> page) {
        return page.map(DisabilityLevelConverter::convertTo);
    }
}